package Threads;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.GregorianCalendar;
import java.util.Scanner;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;

import Interfaces.C_interface;
import Interfaces.S_interface;
import Structs.Member;
import Structs.Msg_rsp;
import Structs.Task;

public class C_RMI extends UnicastRemoteObject implements C_interface {

	private static final long serialVersionUID = 1L;
	/*
	private Integer RMI_port, temp_int;
	private String Username,Password,temp_string;
	private Scanner sc;
	
	private Member client;
	private Task t; 
	
	private BlockingQueue<Msg_rsp> Requests;
	
	private S_interface server;
	*/
	public C_RMI(Integer port,
					BlockingQueue<Msg_rsp> Requests,
					S_interface server,
					Member client) throws RemoteException {
		
		super();
		
	}
	/*
	public void work() throws RemoteException {
		
		Msg_rsp temp;
		
		while(true){
			
			temp = Requests.poll();
			
			switch (temp.getType()){
			
			case Login: 
				
				sc = new Scanner(System.in);
				
				System.out.print("Username: ");
				Username = sc.nextLine();
				
				System.out.print("Password: ");
				Password = sc.nextLine();
				
				if(server.Login(Username, Password, this)){
					
					client.setUser(Username);
					client.setPass(Password);
				}
				
				break;
			
			case Logout:
				
				if(server.Logout(client.getUser())){
					client.setUser("");
					client.setPass("");
				}
				
				
				break;
			
			case Register: 
				
				sc = new Scanner(System.in);
				
				System.out.print("Username: ");
				Username = sc.nextLine();
				
				System.out.print("Password: ");
				Password = sc.nextLine();
			
				if(server.Register(Username, Password)){
			
					client.setUser(Username);
					client.setPass(Password);
				}
				
				break;
			
			case NewTask: 
				
				sc = new Scanner(System.in);
				
				System.out.print("Titulo para a nova Task: ");
				temp_string = sc.nextLine();
				
				server.addTask(temp_string, client, (GregorianCalendar) GregorianCalendar.getInstance());
				
				break;
				
			case EditTask:
				
				sc = new Scanner(System.in);
				
				System.out.print("Id da task a editar: ");
				temp_int = sc.nextInt();
				
				System.out.print("Novo título: ");
				temp_string = sc.nextLine();
				
				server.addTask(temp_int,temp_string, client, (GregorianCalendar) GregorianCalendar.getInstance());
				
				break;
				
			case FinishTask:
				
				sc = new Scanner(System.in);
				
				System.out.print("Id da task a completar: ");
				temp_int = sc.nextInt();
			
				server.addTask(temp_int, "Finish", client, (GregorianCalendar) GregorianCalendar.getInstance());
				
				break;
				
			case ListTasks:
				
				server.addTask("List", client, (GregorianCalendar) GregorianCalendar.getInstance());
				
				break;
			}
		
		}
		
	}
	*/
	public void PrintOnClient(String msg) throws RemoteException {
		
		System.out.println(msg);
		
	}
}
